From 264d4a00cad359b77d54964362c69cc47ea46a8f Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 12 Mar 2014 15:32:47 -0700 Subject: [PATCH] Use cargo conventions for cargo itself --- Makefile | 57 ++++++++++--------- commands/cargo/main.rs | 0 libcargo/Makefile | 14 ----- .../main.rs => src/bin/cargo-read-manifest.rs | 0 .../main.rs => src/bin/cargo-rustc.rs | 0 .../bin/cargo-verify-project.rs | 0 {libcargo => src}/cargo.rs | 1 - 7 files changed, 31 insertions(+), 41 deletions(-) delete mode 100644 commands/cargo/main.rs delete mode 100644 libcargo/Makefile rename commands/cargo-read-manifest/main.rs => src/bin/cargo-read-manifest.rs (100%) rename commands/cargo-rustc/main.rs => src/bin/cargo-rustc.rs (100%) rename commands/cargo-verify-project/main.rs => src/bin/cargo-verify-project.rs (100%) rename {libcargo => src}/cargo.rs (99%) diff --git a/Makefile b/Makefile index 68b1517c9..88b614745 100644 --- a/Makefile +++ b/Makefile @@ -1,41 +1,46 @@ -RUSTC_TARGET = target -RUSTC_FLAGS ?= --out-dir $(RUSTC_TARGET) -L $(RUSTC_TARGET)/libs +RUSTC ?= rustc +# RUSTC_FLAGS ?= --out-dir $(RUSTC_TARGET) -L $(RUSTC_TARGET)/libs TOML_LIB := $(shell rustc --crate-file-name libs/rust-toml/src/toml/lib.rs) HAMMER_LIB := $(shell rustc --crate-file-name libs/hammer.rs/src/hammer.rs) -LIBCARGO_LIB := $(shell rustc --crate-file-name libcargo/cargo.rs) -default: dependencies commands +# Link flags to pull in dependencies +DEPS = -L libs/hammer.rs/target -L libs/rust-toml/lib +SRC = $(wildcard src/*.rs) +BINS = cargo-read-manifest \ + cargo-rustc \ + cargo-verify-project -dependencies: target/libs/$(TOML_LIB) target/libs/$(HAMMER_LIB) target/libs/$(LIBCARGO_LIB) +BIN_TARGETS = $(patsubst %,target/%,$(BINS)) -commands: target/cargo-rustc target/cargo-verify-project target/cargo-read-manifest +all: $(BIN_TARGETS) -clean: - rm -rf target +# Builds the hammer dependency +hammer: + cd libs/hammer.rs && make -target/cargo-rustc: target dependencies target/libs/$(TOML_LIB) commands/cargo-rustc/main.rs - rustc commands/cargo-rustc/main.rs $(RUSTC_FLAGS) +toml: + cd libs/rust-toml && make -target/cargo-verify-project: target dependencies target/libs/$(TOML_LIB) commands/cargo-verify-project/main.rs - rustc commands/cargo-verify-project/main.rs $(RUSTC_FLAGS) +# === Cargo -target/cargo-read-manifest: target dependencies target/libs/$(TOML_LIB) target/libs/$(HAMMER_LIB) commands/cargo-read-manifest/main.rs - rustc commands/cargo-read-manifest/main.rs $(RUSTC_FLAGS) +target: + mkdir -p target -target/libs/$(TOML_LIB): target libs/rust-toml/src/toml/lib.rs - cd libs/rust-toml && make - cp libs/rust-toml/lib/*.rlib target/libs +libcargo: target $(SRC) + $(RUSTC) --out-dir target src/cargo.rs -target/libs/$(HAMMER_LIB): target libs/hammer.rs/src/hammer.rs - cd libs/hammer.rs && make - cp libs/hammer.rs/target/*.rlib target/libs +# === Commands -target/libs/$(LIBCARGO_LIB): target libcargo/cargo.rs - cd libcargo && make - cp libcargo/target/*.rlib target/libs/ +$(BIN_TARGETS): target/%: src/bin/%.rs hammer toml libcargo + $(RUSTC) $(DEPS) -Ltarget --out-dir target $< -target: - mkdir -p $(RUSTC_TARGET)/libs +clean: + rm -rf target + +distclean: clean + cd libs/hamcrest-rust && make clean + cd libs/hammer.rs && make clean + cd libs/rust-toml && make clean -.PHONY: default clean dependencies commands +.PHONY: all clean distclean test hammer libcargo diff --git a/commands/cargo/main.rs b/commands/cargo/main.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/libcargo/Makefile b/libcargo/Makefile deleted file mode 100644 index 03546636a..000000000 --- a/libcargo/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -LIBCARGO_LIB := $(shell rustc --crate-file-name cargo.rs) - -default: target/$(LIBCARGO_LIB) - -target: - mkdir -p target - -clean: - rm -rf target - -target/$(LIBCARGO_LIB): target cargo.rs - rustc cargo.rs --out-dir target - -.PHONY: default clean diff --git a/commands/cargo-read-manifest/main.rs b/src/bin/cargo-read-manifest.rs similarity index 100% rename from commands/cargo-read-manifest/main.rs rename to src/bin/cargo-read-manifest.rs diff --git a/commands/cargo-rustc/main.rs b/src/bin/cargo-rustc.rs similarity index 100% rename from commands/cargo-rustc/main.rs rename to src/bin/cargo-rustc.rs diff --git a/commands/cargo-verify-project/main.rs b/src/bin/cargo-verify-project.rs similarity index 100% rename from commands/cargo-verify-project/main.rs rename to src/bin/cargo-verify-project.rs diff --git a/libcargo/cargo.rs b/src/cargo.rs similarity index 99% rename from libcargo/cargo.rs rename to src/cargo.rs index 7c94661c0..fb0895603 100644 --- a/libcargo/cargo.rs +++ b/src/cargo.rs @@ -32,4 +32,3 @@ pub struct Project { version: ~str, authors: ~[~str] } - -- 2.30.2